<template>
  <div class="app-container">
    <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
      <el-tab-pane label="操作日志" name="log" />
      <el-tab-pane label="登录日志" name="sign" />
      <div class="tab-content">
        <keep-alive>
          <component :is="curTabcompnents[activeName]" />
        </keep-alive>
      </div>
    </el-tabs>
  </div>
</template>

<script>

import logTabPane from './journals/log.vue'
import signTabPane from './journals/sign.vue'

export default {
  name: 'Tab',
  components: { logTabPane, signTabPane },
  data() {
    return {
      activeName: 'log',
      curTabcompnents: {
        'log': 'logTabPane',
        'sign': 'signTabPane'
      }

    }
  },
  watch: {
    activeName(val) {
      this.$router.push(`${this.$route.path}?tab=${val}`)
    }
  },
  created() {
    // init the default selected tab
    const tab = this.$route.query.tab
    if (tab) {
      this.activeName = tab
    }
  },
  methods: {
    handleClick(tab) {
      this.activeName = tab.name
    }
  }
}
</script>

<style lang="scss" scoped>
.app-container{
  padding:0px;
}

</style>
